import React from 'react';
import { connect } from 'dva';
import { createForm } from 'rc-form';
import cx from 'classnames';
import { WingBlank, WhiteSpace, DatePicker, Picker, InputItem, Flex, List, Button, Toast } from 'antd-mobile';
import { Link, routerRedux } from 'dva/router';
import styles from '../scale/styles.less';
import {  SCALE_PREPRE } from 'const';
Array.prototype.unique2 = function(){
 this.sort(); //先排序
 var res = [this[0]];
 for(var i = 1; i < this.length; i++){
  if(this[i] !== res[res.length - 1]){
   res.push(this[i]);
  }
 }
 return res;
}

Array.prototype.remove = function(val) { 
  var index = this.indexOf(val); 
  if (index > -1) { 
  this.splice(index, 1); 
  } 
};
function isInArray(arr,value){
    for(var i = 0; i < arr.length; i++){
        if(value === arr[i]){
            return true;
        }
    }
    return false;
}

function ScalePrePreTemplate({ dispatch, location, form, scalevalue , detail, ...rest }) {
  
  const { state, query } = location;
  
  const { type, patientid, step, patientvalue, birthday} = location.state;
  const { getFieldProps, getFieldValue, setFieldsValue, validateFields, getFieldError } = form;
  let question = SCALE_PREPRE[step];

  const isNativeApp = location.pathname.indexOf('/scale_prepre') !== -1 && query.s === 'app';

  if (!Object.keys(scalevalue).length) {
    scalevalue = [[], []];
    dispatch({ type: 'scale/save', payload: { scalevalue } });
  }

  let infos = scalevalue[0] || []; //用户信息

  let scores = scalevalue[1] || []; //症状
  
  let nextStep = step + 1;
  const category = step - 2;
  let title = '';
  if (step === 1) {
    title = '完善用户信息';
  }

  let stepQuestions = [];
  if (category >= 0 && category < 6) {
    stepQuestions = SCALE_PREPRE[category].subject;
    title = SCALE_PREPRE[category].title;
  }

  const jwData = [{ label: '大失血病史（大于400ml）', id: '9' },{ label: '子宫内膜异位症', id: '10' }, { label: '子宫肌瘤', id: '11' },{ label: '其他', id: '1001' }];
  const iszrData = [{ label: '有', value: '1' }, { label: '无', value: '0' }];
  const iszrDataA = [{ label: '无', value: '0' }];
  const isrgData = [{ label: '有', value: '1' }, { label: '无', value: '0' }];
  const isrgDataA = [{ label: '无', value: '0' }];
  const isrgDataB = [{ label: '有', value: '1' }];
  const isReturnData = [{ label: '初诊', value: '0' }, { label: '复诊', value: '1' }];

  const validateForm = () => {

  validateFields((err, values) => {
    if (err) {
        const fieldNames = Object.keys(err);
        if (fieldNames[0]) {
          return Toast.fail(getFieldError(fieldNames[0]));
        }
    } else {
      if (step === 1) {
          const jw = [];
          for (var i = jwData.length - 1; i >= 0; i--) {
            if (values[jwData[i].id]) {
              jw.push(jwData[i].id);
            }
          }
          if (getFieldValue("hy") < getFieldValue("sc")) {
            setFieldsValue({["hy"]: null});
            setFieldsValue({["sc"]: null});
            return Toast.fail("怀孕次数不得小于生产次数", 1);
          }
        const isReturn = getFieldValue('isReturn');
        const height = getFieldValue('height'); // 身高
        const weight = getFieldValue('weight'); // 体重
        const hy = getFieldValue('hy');// 怀孕次数
        const sc = getFieldValue('sc');// 生产次数
        const natural = getFieldValue('natural'); // 自然流产史
        const artificial = getFieldValue('artificial'); // 人工流产史
        let JWS = jw.reverse(';');
        if (JWS) {
          for (var i = JWS.length - 1; i >= 0; i--) {
            scores.push(JWS[i]);//即往病史
          }
        }

        infos = [hy, natural, height, weight, artificial , sc, isReturn, jw];
        dispatch({ type: 'scale/save', payload: { scalevalue: [infos, scores] } });
      }
      if (step > 1) {
          Object.keys(values).forEach((key) => {
            if (values[key]) {
              scores.push(key);
            }
            // 月经周期小于25天&& 月经量极少，点滴而已 == 月经量极少，点滴而已且月经周期小于25天 id:133
             //"月经过多" && "经血色淡" == 月经过多且月经色淡 id: 134
          });
        }

        dispatch({ type: 'scale/save', payload: { scalevalue: [infos, scores] } });

        if (nextStep <= 7) {
          let pathname = location.pathname;

          if (isNativeApp) {
            pathname = `${location.pathname}?s=${query.s}&doctorid=${query.doctorid}&memberid=${query.memberid}`;
            
          }
          dispatch(
            routerRedux.replace({
              pathname,
              state: {
                type,
                patientid,
                step: nextStep,
              },
            }),
          );
        } else {

           if(scores.length <= 3){
              Toast.fail('选择的症状信息过少，请重新选择');
           }else if(scores.length > 3){
              //年龄（虚岁）= 以测试年- 出生年 + 1
              let BWI = infos[3]/infos[2];
              if (BWI<18.5){
                  scores.push("5");//肥胖
              }
              if (BWI>25){
                  scores.push("6");//消瘦
              }
              let liucan = infos[0] - infos[5];
              if(liucan >2){
                  scores.push("8");//流产大于两次 
              }
              let lactation = "7";
              if( infos[1]== 0){
                  scores.push(lactation);//人工流产史
              }
              let time = new Date(); let times = new Date(birthday);
              let newYear = time.getFullYear(), oldYear = times.getFullYear();
              let year = newYear - oldYear;
              if(year<=41 && year>=35){
                 scores.push("2");//35≤年龄 ≤41
              }
              if(year<=52 && year>=42){
                 scores.push("3");//42≤年龄 ≤52 
              }

              scores = scores.unique2();
              if(isInArray(scores,'19') && isInArray(scores,'23')){
                 scores.remove("19");
                 scores.remove("23");
                 scores.push("133");
              }
              if(isInArray(scores,'21') && isInArray(scores,'25')){
                 scores.remove("21");
                 scores.remove("25");
                 scores.push("134");
              }
              const patientValue = `${scores.join(',')}`;
              dispatch({
                  type: 'scale/submitScaleByUsers',
                  payload: {
                    type: location.state.type,
                    patientId: state.patientid,
                    familyId: JSON.parse(localStorage.getItem("auth"+sessionStorage.getItem("hid"))).patientId,
                    patientValue,
                    jw: infos[7].join(','), 
                    hy: infos[0],
                    sc: infos[5],
                    height: infos[2],
                    weight: infos[3],
                    isReturn: infos[6],
                    isMiscarriage: infos[1],
                    isAbortion: infos[4],
                    ...rest,
                  },
                });
              }
           }
         }
     });
   };

   function isDisable(name, value, i){
     if(getFieldValue(18) && name == 19 || getFieldValue(19) && name == 18){
        return true;
      }
      
      if (scalevalue[1] && scalevalue[1].indexOf("18")!= -1 && name == 19) {
          return true;
      }
      if (scalevalue[1] && scalevalue[1].indexOf("19")!= -1 && name == 18) {
          return true;
      }
      if(getFieldValue(21) && name == 22 || getFieldValue(22) && name == 21){
           return true;
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("21")!= -1 && name == 22) {
           return true;
      }
      if (scalevalue[1] && scalevalue[1].indexOf("22")!= -1 && name == 21) {
           return true;
      }
      if(getFieldValue(21) && name == 23 || getFieldValue(23) && name == 21){
           return true;
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("21")!= -1 && name == 23) {
           return true;
      }
      if (scalevalue[1] && scalevalue[1].indexOf("23")!= -1 && name == 21) {
           return true;
      }
      if(getFieldValue(24) && name == 25 || getFieldValue(25) && name == 24){
           return true;
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("24")!= -1 && name == 25) {
           return true;
      }
      if (scalevalue[1] && scalevalue[1].indexOf("25")!= -1 && name == 24) {
           return true;
      }
      if(getFieldValue(22) && name == 23 || getFieldValue(23) && name == 22){
           return true;
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("22")!= -1 && name == 23) {
           return true;
      }
      if (scalevalue[1] && scalevalue[1].indexOf("23")!= -1 && name == 22) {
           return true;
      }
      if(getFieldValue(24) && name == 27 || getFieldValue(27) && name == 24){
           return true;
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("24")!= -1 && name == 27) {
           return true;
      }
      if (scalevalue[1] && scalevalue[1].indexOf("27")!= -1 && name == 24) {
           return true;
      }
      if(getFieldValue(60) && name == 64 || getFieldValue(64) && name == 60){
           return true;
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("60")!= -1 && name == 64) {
           return true;
      }
      if (scalevalue[1] && scalevalue[1].indexOf("64")!= -1 && name == 60) {
           return true;
      }
      if(getFieldValue(86) && name == 87 || getFieldValue(87) && name == 86){
           return true;
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("86")!= -1 && name == 87) {
           return true;
      }
      if (scalevalue[1] && scalevalue[1].indexOf("87")!= -1 && name == 86) {
           return true;
      }
      if(getFieldValue(111) && name == 112 || getFieldValue(112) && name == 111){
           return true;
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("111")!= -1 && name == 112) {
          return true;
      }
      if (scalevalue[1] && scalevalue[1].indexOf("112")!= -1 && name == 111) {
          return true;
      }
      if(getFieldValue(111) && name == 113 || getFieldValue(113) && name == 111){
          return true;
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("111")!= -1 && name == 113) {
          return true;
      }
      if (scalevalue[1] && scalevalue[1].indexOf("113")!= -1 && name == 111) {
          return true;
      }
      if(getFieldValue(90) && name == 142 || getFieldValue(142) && name == 90){
          return true;
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("90")!= -1 && name == 142) {
          return true;
      }
      if (scalevalue[1] && scalevalue[1].indexOf("142")!= -1 && name == 90) {
          return true;
      }
      if(getFieldValue(91) && name == 93 || getFieldValue(93) && name == 91){
          return true;
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("91")!= -1 && name == 93) {
          return true;
      }
      if (scalevalue[1] && scalevalue[1].indexOf("93")!= -1 && name == 91) {
          return true;
      }
       if(getFieldValue(132) && name == 1002 || getFieldValue(1002) && name == 132){
          return true;
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("132")!= -1 && name == 1002) {
          return true;
      }
      if (scalevalue[1] && scalevalue[1].indexOf("1002")!= -1 && name == 132) {
          return true;
      }
      return false;
   }

   function isActive(key, value, i) {
     if (Array.from(scores).find(item => item === key)) {
        return true;
      }

      if (!getFieldValue(key)) {
        return false;
      }

      return getFieldValue(key) === value;
   }

   function handleChange({ target: { type, name, value } }) {
      if (Array.from(scores).find(item => item === name)) {
        setFieldsValue({ [name]: value }); //form实际值与状态不符，用赋值保持相符
        scores = Array.from(scores).filter(item => item !== name); //从scores中去除
      }
      if (getFieldValue(name) === value) {
          setFieldsValue({ [name]: null });
      } else {
          setFieldsValue({ [name]: value });
      }
      if(getFieldValue(18) && name == 19 || getFieldValue(19) && name == 18){
          setFieldsValue({ [name]: null });
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("18")!= -1 && name == 19) {
          setFieldsValue({ [name]: null });
      }
      if (scalevalue[1] && scalevalue[1].indexOf("19")!= -1 && name == 18) {
          setFieldsValue({ [name]: null });
      }
      if(getFieldValue(21) && name == 22 || getFieldValue(22) && name == 21){
          setFieldsValue({ [name]: null });
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("21")!= -1 && name == 22) {
          setFieldsValue({ [name]: null });
      }
      if (scalevalue[1] && scalevalue[1].indexOf("22")!= -1 && name == 21) {
          setFieldsValue({ [name]: null });
      }
      if(getFieldValue(21) && name == 23 || getFieldValue(23) && name == 21){
          setFieldsValue({ [name]: null });
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("21")!= -1 && name == 23) {
          setFieldsValue({ [name]: null });
      }
      if (scalevalue[1] && scalevalue[1].indexOf("23")!= -1 && name == 21) {
          setFieldsValue({ [name]: null });
      }
      if(getFieldValue(24) && name == 25 || getFieldValue(25) && name == 24){
          setFieldsValue({ [name]: null });
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("24")!= -1 && name == 25) {
          setFieldsValue({ [name]: null });
      }
      if (scalevalue[1] && scalevalue[1].indexOf("25")!= -1 && name == 24) {
          setFieldsValue({ [name]: null });
      }
      if(getFieldValue(22) && name == 23 || getFieldValue(23) && name == 22){
          setFieldsValue({ [name]: null });
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("22")!= -1 && name == 23) {
          setFieldsValue({ [name]: null });
      }
      if (scalevalue[1] && scalevalue[1].indexOf("23")!= -1 && name == 22) {
          setFieldsValue({ [name]: null });
      }
      if(getFieldValue(24) && name == 27 || getFieldValue(27) && name == 24){
          setFieldsValue({ [name]: null });
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("24")!= -1 && name == 27) {
          setFieldsValue({ [name]: null });
      }
      if (scalevalue[1] && scalevalue[1].indexOf("27")!= -1 && name == 24) {
          setFieldsValue({ [name]: null });
      }
      if(getFieldValue(60) && name == 64 || getFieldValue(64) && name == 60){
          setFieldsValue({ [name]: null });
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("60")!= -1 && name == 64) {
          setFieldsValue({ [name]: null });
      }
      if (scalevalue[1] && scalevalue[1].indexOf("64")!= -1 && name == 60) {
          setFieldsValue({ [name]: null });
      }
      if(getFieldValue(86) && name == 87 || getFieldValue(87) && name == 86){
          setFieldsValue({ [name]: null });
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("86")!= -1 && name == 87) {
          setFieldsValue({ [name]: null });
      }
      if (scalevalue[1] && scalevalue[1].indexOf("87")!= -1 && name == 86) {
          setFieldsValue({ [name]: null });
      }
      if(getFieldValue(111) && name == 112 || getFieldValue(112) && name == 111){
          setFieldsValue({ [name]: null });
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("111")!= -1 && name == 112) {
          setFieldsValue({ [name]: null });
      }
      if (scalevalue[1] && scalevalue[1].indexOf("112")!= -1 && name == 111) {
          setFieldsValue({ [name]: null });
      }
      if(getFieldValue(111) && name == 113 || getFieldValue(113) && name == 111){
          setFieldsValue({ [name]: null });
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("111")!= -1 && name == 113) {
          setFieldsValue({ [name]: null });
      }
      if (scalevalue[1] && scalevalue[1].indexOf("113")!= -1 && name == 111) {
          setFieldsValue({ [name]: null });
      }
      if(getFieldValue(90) && name == 142 || getFieldValue(142) && name == 90){
          setFieldsValue({ [name]: null });
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("90")!= -1 && name == 142) {
          setFieldsValue({ [name]: null });
      }
      if (scalevalue[1] && scalevalue[1].indexOf("142")!= -1 && name == 90) {
          setFieldsValue({ [name]: null });
      }
      if(getFieldValue(91) && name == 93 || getFieldValue(93) && name == 91){
          setFieldsValue({ [name]: null });
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("91")!= -1 && name == 93) {
          setFieldsValue({ [name]: null });
      }
      if (scalevalue[1] && scalevalue[1].indexOf("93")!= -1 && name == 91) {
          setFieldsValue({ [name]: null });
      }
       if(getFieldValue(132) && name == 1002 || getFieldValue(1002) && name == 132){
          setFieldsValue({ [name]: null });
      }
     
      if (scalevalue[1] && scalevalue[1].indexOf("132")!= -1 && name == 1002) {
          setFieldsValue({ [name]: null });
      }
      if (scalevalue[1] && scalevalue[1].indexOf("1002")!= -1 && name == 132) {
          setFieldsValue({ [name]: null });
      }


      dispatch({ type: 'scale/save', payload: { scalevalue: [infos, scores] } });         
   }
   function nextHandler() {
     window.scrollTo(0, 0);
     nextStep = step + 1;
     validateForm();
   }

   function prevHandler() {
     window.scrollTo(0, 0);
     nextStep = step - 1;
     validateForm();
   }

   function submitHandler() {
     nextStep = step + 1;
     validateForm();
   }
   function isBlur(type,value){
    if (type == "height") {
      if (value < 0 || value > 300) {
        setFieldsValue({[type]: null});
        return Toast.fail("请输入正确的身高0~300cm！", 1);
      }
    }
    if (type == "weight") {
      if (value < 20 || value > 200) {
        setFieldsValue({[type]: null});
        return Toast.fail("请输入正确的体重20~200kg！", 1);
      }
    }
    if (type == "hy") {
      if (value <0) {
        // 之前是需要判断1-4次, 因为产后症状对应表的原因。
        setFieldsValue({[type]: null});
        return Toast.fail("请输入正确的怀孕次数1次以上！", 1);
      }
    }
    if (type == "sc") {
      if (value <0) {
        setFieldsValue({[type]: null});
        return Toast.fail("生产次数大于等于1并小于等于怀孕次数", 1);
      }
    }
  }

  return (
    <WingBlank size="md">
      <WhiteSpace />
      <List>
          <List.Item>
            <Flex justify="center">{`${step}/7 ${title || detail.Title}`}</Flex>
            {step!==1?
            <div><Flex justify="center" style={{fontSize: '0.25rem',marginTop: '0.1rem'}}>请您按近期3个月的身体状况进行选择</Flex>
            <Flex justify="center" style={{fontSize: '0.25rem'}}>（有即选，无则不选，可以多选）</Flex></div>:""}
          </List.Item>
          {step === 1
          ? /*第1页自定义表单*/
            <div>
               <Picker
                data={isReturnData}
                {...getFieldProps('isReturn', {
                  initialValue: infos[6] || '',
                  validate: [
                    {
                      trigger: false,
                      rules: [{ required: true, message: '请选择初诊/复诊' }],
                    },
                  ],
                })}
              >
                <List.Item arrow="horizontal">初诊/复诊</List.Item>
              </Picker>
              <InputItem
                {...getFieldProps('height', {
                  initialValue: infos[2] || '',
                  validate: [
                    {
                      trigger: false,
                      rules: [{ required: true, message: '请输入身高' }],
                    },
                  ],
                  normalize:(v, prev) => {
                    if (v && !/^(([1-9]\d*)|0)(\.\d{0,1}?)?$/.test(v)) {
                      if (v === '.') {
                        return '0.';
                      }
                      return prev;
                    }
                    return v;
                  },
                })}
                placeholder="请输入身高"
                type="digit" 
                onBlur={() => isBlur("height",getFieldValue('height'))}
              >
                身高(cm)
              </InputItem>
               <InputItem
                {...getFieldProps('weight', {
                  initialValue: infos[3] || '',
                  validate: [
                    {
                      trigger: false,
                      rules: [{ required: true, message: '请输入体重' }],
                    },
                  ],
                  normalize:(v, prev) => {
                    if (v && !/^(([1-9]\d*)|0)(\.\d{0,1}?)?$/.test(v)) {
                      if (v === '.') {
                        return '0.';
                      }
                      return prev;
                    }
                    return v;
                  },
                })}
                placeholder="请输入体重"
                type="digit" 
                onBlur={() => isBlur("weight",getFieldValue('weight'))}
              >
                体重(kg)
              </InputItem>
              <InputItem
                {...getFieldProps('hy', {
                  initialValue: infos[0] || '',
                  validate: [
                    {
                      trigger: false,
                      rules: [{ required: true, message: '请输入怀孕次数' }],
                    },
                  ],
                })}
                placeholder="请输入怀孕次数"
                type="number"
                onBlur={() => isBlur("hy",getFieldValue('hy'))}
              >
                怀孕次数
              </InputItem>
              <InputItem
                {...getFieldProps('sc', {
                  initialValue: infos[5] || '',
                  validate: [
                    {
                      trigger: false,
                      rules: [{ required: true, message: '请输入生产次数' }],
                    },
                  ],
                })}
                placeholder="请输入生产次数"
                type="number"
                onBlur={() => isBlur("sc",getFieldValue('sc'))}
              >
                生产次数
              </InputItem>
                       { getFieldValue('sc') - getFieldValue('hy') == 0?
              <div>
              <Picker
                data={iszrDataA}
                {...getFieldProps('natural', {
                  initialValue: infos[1] || '',
                  validate: [
                    {
                      trigger: false,
                      rules: [{ required: true, message: '请选择有／无' }],
                    },
                  ],
                })}
              >
                <List.Item arrow="horizontal">自然流产史</List.Item>
              </Picker>
              <Picker
                data={isrgDataA}
                {...getFieldProps('artificial', {
                  initialValue: infos[4] || '',
                  validate: [
                    {
                      trigger: false,
                      rules: [{ required: true, message: '请选择有／无' }],
                    },
                  ],
                })}
              >
                <List.Item arrow="horizontal">人工流产史</List.Item>
              </Picker></div>:(
                getFieldValue('hy') - getFieldValue('sc') == 1?  <div>
              <Picker
                data={iszrData}
                {...getFieldProps('natural', {
                  initialValue: infos[1] || '',
                  validate: [
                    {
                      trigger: false,
                      rules: [{ required: true, message: '请选择有／无' }],
                    },
                  ],
                })}
              >
                <List.Item arrow="horizontal">自然流产史</List.Item>
              </Picker>
              <Picker
                data={getFieldValue('natural')== 1 ? isrgDataA : isrgDataB}
                {...getFieldProps('artificial', {
                  initialValue: infos[4] || '',
                  validate: [
                    {
                      trigger: false,
                      rules: [{ required: true, message: '请选择有／无' }],
                    },
                  ],
                })}
              >
                <List.Item arrow="horizontal">人工流产史</List.Item>
              </Picker></div>: (
                getFieldValue('hy') - getFieldValue('sc') >= 2? <div>
              <Picker
                data={iszrData}
                {...getFieldProps('natural', {
                  initialValue: infos[1] || '',
                  validate: [
                    {
                      trigger: false,
                      rules: [{ required: true, message: '请选择有／无' }],
                    },
                  ],
                })}
              >
                <List.Item arrow="horizontal">自然流产史</List.Item>
              </Picker>
              <Picker
                data={getFieldValue('natural')== 1 ? isrgData : isrgDataB}
                {...getFieldProps('artificial', {
                  initialValue: infos[4] || '',
                  validate: [
                    {
                      trigger: false,
                      rules: [{ required: true, message: '请选择有／无' }],
                    },
                  ],
                })}
              >
                <List.Item arrow="horizontal">人工流产史</List.Item>
              </Picker></div>:<div>
              <Picker
                data={iszrData}
                {...getFieldProps('natural', {
                  initialValue: infos[1] || '',
                  validate: [
                    {
                      trigger: false,
                      rules: [{ required: true, message: '请选择有／无' }],
                    },
                  ],
                })}
              >
                <List.Item arrow="horizontal">自然流产史</List.Item>
              </Picker>
              <Picker
                data={isrgData}
                {...getFieldProps('artificial', {
                  initialValue: infos[4] || '',
                  validate: [
                    {
                      trigger: false,
                      rules: [{ required: true, message: '请选择有／无' }],
                    },
                  ],
                })}
              >
                <List.Item arrow="horizontal">人工流产史</List.Item>
              </Picker></div>)
              )}
              <List.Item key="jw">
                既往病史
                <List.Item.Brief>
                  <Flex wrap="wrap" className={styles.questionOptions}>
                    {jwData.map((option, i) => {
                      const key = option.id;
                      const value = option.label;
                      return (
                        <label key={key} className={cx(styles.questionOption, styles.questionOptionNormal, { [styles.questionOptionActive]: isActive(key, value, i) })}>
                          <input {...getFieldProps(`${key}`)} type="checkbox" name={key} value={value} checked={isActive(key, value, i)} onChange={handleChange} />
                          {value}
                        </label>
                      );
                    })}
                  </Flex>
                </List.Item.Brief>
              </List.Item>
            </div>
            : /*第2-7页动态题目*/
            stepQuestions.map((question, i) => (
              <List.Item wrap multipleLine key={question.id}>
                {`${i + 1}. ${question.title}`}
                <List.Item.Brief>
                  <Flex wrap="wrap" className={styles.questionOptions}>
                    {question.item.map((option, i) => {
                      const key = option.id;
                      const value = option.title;
                      return (
                        <label 
                          key={key} className={cx(styles.questionOption, styles.questionOptionNormal, { 
                            [styles.questionOptionActive]: isActive(key, value, i),
                            [styles.questionOptionDisable]: isDisable(key, value, i), })}>
                          <input {...getFieldProps(`${key}`)} type="checkbox" name={key} value={value} checked={isActive(key, value, i)} onChange={handleChange} />
                          {value}
                        </label>
                      );
                    })}
                  </Flex>
                </List.Item.Brief>
              </List.Item>
            ))}
          <div>
            <WhiteSpace size="xl" />
            <WingBlank>
              <Flex>
                {step === 1
                  ? null
                  : <Flex.Item>
                    <Button onClick={prevHandler}>上一页</Button>
                  </Flex.Item>}

                {step < 7 
                  ? <Flex.Item>
                    <Button type="primary" onClick={nextHandler}>下一页</Button>
                  </Flex.Item>
                  : <Flex.Item>
                    <Button type="primary" onClick={submitHandler}>提交</Button>
                  </Flex.Item>}

              </Flex>
            </WingBlank>
            <WhiteSpace size="xl" />
          </div>
      </List>
      <WhiteSpace size="xl" />
    </WingBlank>
  )

}

export default connect(({ scale }) => ({ ...scale }))(createForm()(ScalePrePreTemplate));